﻿<?php
if (!isset($_REQUEST['action'])) {
    $_REQUEST['action'] = 'demandeConnexion';
}
$action = $_REQUEST['action'];
switch ($action) {

    case 'visualiserEntreprise': {
            include '../include/LesEntreprises.php';
            include('../vues/v_gererLesEntreprises.php');
            $resultat = LesEntreprises::visualiserEntreprise();


            break;
        }

    case 'creerEntreprise2': {

            include '../vues/v_creerEntreprise.php';
            break;
        }

    case 'enregistrerEntreprise': {
//            include './include/LesEntreprises.php';
//
//            $nomEntreprise = $_POST['nomEntreprise'];
//            $adresseEntreprise = $_POST['adresseEntreprise'];
//            $nomContact = $_POST['nomContact'];
//            $courielContact = $_POST['courielContact'];
//            $themeStage = $_POST['themeStage'];
//            $periodeDebut = $_POST['periodeDebut'];
//            $periodeFin = $_POST['periodeFin'];
//            
//            LesEntreprises::ajouterEntreprise($nomEntreprise, $adresseEntreprise, $nomContact, $courielContact, $themeStage, $periodeDebut, $periodeFin);
//            header("Location:index.php?uc=entreprise&action=visualiserEntreprise");

            break;


        
        }
        case'modifEntreprise':{
                include '../vues/v_modifierEntreprise.php';
                break;
            
        }
        
    case 'enregistreModif' : {
            include '../include/LesEntreprises.php';
            $idEntreprise=$_POST['idEntreprise'];
         
            $nomEntreprise = $_POST['nomEntreprise'];
            $adresseEntreprise = $_POST['adresseEntreprise'];
            $nomContact = $_POST['nomContact'];
            $courielContact = $_POST['courielContact'];
            $themeStage = $_POST['themeStage'];
            $periodeDebut = $_POST['periodeDebut'];
            $periodeFin = $_POST['periodeFin'];
            
            LesEntreprises::enregistrerModifEntreprise($nomEntreprise, $adresseEntreprise, $nomContact, $courielContact, $themeStage, $periodeDebut, $periodeFin, $idEntreprise);
          header("Location:index.php?uc=entreprise&action=visualiserEntreprise");
            break;
        
                
    }
    
    case'recherche': {
            include './include/LesEntreprises.php';
            $recherche=$_POST['recherche'];
            
            if(is_numeric($recherche)){
                LesEntreprises::rechercheAnnee($recherche);
                include './vues/v_gererLesEntreprisesRecherche.php';
            }else{
                LesEntreprises::recherchemotcle($recherche);
                include './vues/v_gererLesEntreprisesRechercheMotCle.php';
            }
            
            
            break;
            
        
    }
}

    
    
